package com.aggregate.pay.sanstar.support.client;

import com.aggregate.pay.sanstar.Result;
import com.aggregate.pay.sanstar.bean.TerminalBindResult;
import com.aggregate.pay.sanstar.support.AbstractClient;
import com.aggregate.pay.sanstar.support.Factory;
import com.aggregate.pay.sanstar.support.Merch;

/**
 * 终端签到接口
 * @author Moyq5
 * @date 2020年12月18日
 */
public class TerminalSign extends AbstractClient<Void, TerminalBindResult> {
    private static Result<TerminalBindResult> signResult;
    private static long signTime = 0;

	public TerminalSign(Merch merch) {
		super(merch);
	}

	@Override
	protected String getServerPath() {
		return Factory.getConfig().getServerPath() + "/terminal/sign";
	}

	@Override
	protected Class<TerminalBindResult> getResultClass() {
		return TerminalBindResult.class;
	}

	@Override
	protected boolean isVerifySign() {
		return false;
	}

    @Override
    protected Result<TerminalBindResult> doExecute(Void data) throws Exception {
        synchronized (TerminalSign.class) {
            if (signTime > System.currentTimeMillis() - 1000) {
                return signResult;
            }
            signResult = super.doExecute(data);
            signTime = System.currentTimeMillis();
            return signResult;
        }
    }
	
}
